using System.Collections.Generic;
using OracleInternal.Common;
using OracleInternal.SqlAndPlsqlParser.LocalParsing;

namespace OracleInternal.SqlAndPlsqlParser.RuleProcessors.ODPCommands
{
	internal static class OracleMbEarleySqlPlusCommandRuleMultiProcessors
	{
		public static OracleMbEarleyRuleMultiProcessorAddItem[] s_vRuleProcessorItems;

		static OracleMbEarleySqlPlusCommandRuleMultiProcessors()
		{
			OracleMbEarleyRuleMultiProcessorAddItem[] array = new OracleMbEarleyRuleMultiProcessorAddItem[2];
			OracleMbEarleyRuleMultiProcessorAddItem oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sqlplus_command",
				m_vRHSSymbols = new string[1]
				{
					"sqlplus_command#"
				},
				m_vRuleProcessor = Process_SqlPlusCommand_SqlPlusCommandNN_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.AllRulesStartingWith
			};
			array[0] = oracleMbEarleyRuleMultiProcessorAddItem;
			oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sqlplus_command#",
				m_vRHSSymbols = new string[1]
				{
					"EXECUTE"
				},
				m_vRuleProcessor = Process_SqlPlusCommandNN_EXECUTE_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.SpecificRule
			};
			array[1] = oracleMbEarleyRuleMultiProcessorAddItem;
			s_vRuleProcessorItems = array;
		}

		public static object Process_SqlPlusCommand_SqlPlusCommandNN_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			object obj = null;
			if (ctx.CurrentRule.IsUnary)
			{
				return OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(ctx.CurrentParseNode, ctx.CurrentRuleIndex + 1, -1, ctx);
			}
			return OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(ctx.CurrentParseNode.Children()[ruleMatchPosition], 0, -1, ctx);
		}

		public static object Process_SqlPlusCommandNN_EXECUTE_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			OracleLpParserContext oracleLpParserContext = (OracleLpParserContext)ctx;
			List<LexerToken> tokens = ctx.Tokens;
			ParseNode currentParseNode = ctx.CurrentParseNode;
			int vBegin = tokens[currentParseNode.From].m_vBegin;
			int vEnd = tokens[currentParseNode.To - 1].m_vEnd;
			OracleLpTextFragment oracleLpTextFragment2 = (oracleLpParserContext.CurrentStatementText = new OracleLpTextFragment(ctx.Script, vBegin, vEnd - vBegin));
			OracleLpStatement result = (oracleLpParserContext.CurrentStatement = new OracleLpExecuteStatement(oracleLpParserContext.CurrentStatementText, (IOracleMetadata)oracleLpParserContext.GetActiveObject(0)));
			oracleLpParserContext.HandleBindVariables = true;
			return result;
		}
	}
}
